home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 2 / Macwelt DVD 2.cdr / System / Entwickler-Tools / macos9 / Future Basic 3 6.0.3 / HTML Rendering.INCL / HTML Rendering.INCL
Encoding:
Text File  |  2002-03-03  |  2.7 KB  |  124 lines  |  [TEXT/FB^e]

  1. /*
  2.      HTML Rendering Example
  3.      Chris Stasny, 1 June 00
  4.  
  5. Made into an INCL March 2001 Andy Pritchard
  6.  
  7. Call HMTL from your programs and PG via FN dohtml (See below)
  8.  
  9. */
  10. '
  11. INCLUDE "Tlbx HTML Rendering.Incl"
  12. '
  13. begin globals
  14. DIM gHRref AS LONG // heavily used HR reference
  15. DIM @gPort& AS LONG// "@" means don't use register
  16. DIM gResizeFlag // bool: window will be resized
  17. end globals
  18. '
  19. '~Utility Routines
  20. /*
  21.  This routine sets the size of the HTML
  22.  rendering rect so that it fits in the 
  23.  current grafport.
  24. */
  25. LOCAL
  26. DIM  renderRect AS RECT
  27. DIM err
  28. LOCAL FN setHTMLrect
  29. gResizeFlag = _false
  30. renderRect  = @gPort&.portRect%
  31. call OFFSETRECT(renderRect,1,0)
  32. call INSETRECT(renderRect,0,-1)
  33. err = FN HRSetRenderingRect(gHRref,renderRect)
  34. END FN
  35. /*
  36.      Check to see if rencering is available.
  37.      Create a new HR reference.
  38.      Set up default values.
  39.      Build a file spec to an HTML file.
  40.      Render the file.
  41. */
  42. local
  43. dim spec as fsspec
  44. dim err,wTitle$
  45. local fn showLocalURL(theURL$,vRef%)
  46. long if fn HRHTMLRenderingLibAvailable
  47. err = fn HRNewReference(gHRref,_kHRRendererHTML32Type,gPort&)
  48. fn setHTMLrect
  49. long if fn FBmakefsspec(vRef%,0,theURL$,spec) = _noErr
  50. long if fn HRGoToFile(gHRref,spec,_false,_zTrue) = _noErr
  51. long if fn HRGetTitle(gHRref,wTitle$) = _noErr
  52. call setwtitle(gPort&,wTitle$)
  53. end if
  54. end if
  55. end if
  56. end if
  57. end fn
  58. /*
  59.      On exit, dispose of the HR reference.
  60. */
  61. local
  62. dim err
  63. local fn terminate
  64. err = fn HRDisposeReference(gHRref)
  65. end fn
  66. '~'6
  67. _htmlInit=1
  68. _htmlOpen=2
  69. _htmlButton=3
  70. _htmlRefresh=4
  71. _htmlResize=6
  72. _htmlClose=7
  73. /*
  74. Control routine
  75.  
  76. FN dohtml(_htmlInit) 'immediately after pGBuild(_windowAnyname)
  77. FN dohtml(_htmlOpen) 'immediately after FN dohtml(_htmlInit)
  78.                          - change this to point to your HTML file
  79. FN dohtml(_htmlButton)  'in Button action and Mouse actions for your windowclass
  80. FN dohtml(_htmlRefresh) 'in windowupdate for your windowclass
  81. FN dohtml(_htmlResize)  'in windowrefresh for your windowclass
  82. FN dohtml(_htmlClose)   'in windowclose for your windowclass
  83.  
  84. */
  85. local fn dohtml(myaction)
  86. dim 63 fName$
  87. DIM ref,err,vRef%,rgn&
  88. select myaction
  89. '~'6
  90. case _htmlInit//init
  91. call GETPORT(gPort&)
  92. '~'6
  93. case _htmlOpen// _openItem
  94. 'Change to point to your local HTML file
  95. vRef%  = SYSTEM(_aplvol)
  96. fName$ = "my_help_file.htm" 'original name, huh? :-)
  97. LONG IF fName$[0]
  98. FN showLocalURL(fName$,vRef%)
  99. END IF
  100. err = fn HRActivate(gHRref)// _wndActivate
  101. '~'6
  102. case _htmlButton
  103. long if fn HRIsHREvent(event)
  104. % event,0
  105. xelse
  106. if gResizeFlag then fn setHTMLrect
  107. end if
  108. '~'6
  109. case _htmlRefresh//_wndRefresh
  110. rgn& = fn newrgn
  111. call rectrgn(rgn&,gPort&.portRect%)
  112. err = fn HRdraw(gHRref,rgn&)
  113. call disposergn(rgn&)
  114. '~'6
  115. case _htmlResize//Resize
  116. fn setHTMLrect
  117. '~'6
  118. case _htmlClose// _wndClose
  119. fn terminate
  120. '~'6
  121. end select
  122. end fn
  123.  
  124.